package com.lanchetech.dao;

import com.lanchetech.bean.request.ListByTimeReq;import com.lanchetech.bean.request.PageReq;import com.lanchetech.bean.request.TimeTypeReq;import com.lanchetech.bean.request.UserCommissionReq;import com.lanchetech.bean.response.UserCommissionResp;import com.lanchetech.bean.vo.*;import com.lanchetech.entity.UserCommission;
import java.math.BigDecimal;import java.util.Collection;import java.util.Date;import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface UserCommissionMapper {
    int deleteByPrimaryKey(Long id);

    int insert(UserCommission record);

    int insertSelective(UserCommission record);

    UserCommission selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserCommission record);

    int updateByPrimaryKey(UserCommission record);

    int updateBatch(List<UserCommission> list);

    int updateBatchSelective(List<UserCommission> list);

    int batchInsert(@Param("list") List<UserCommission> list);

    List<UserCommissionResp> findAllPage(UserCommissionReq req);

    /**
     * 统计已经解冻的佣金总额
     *
     * @param superiorId
     * @param status
     * @param freezeTime
     * @return
     */
    BigDecimal sumThaw(@Param("superiorId") Long superiorId, @Param("status") Byte status, @Param("freezeTime") Date freezeTime);

    int updateStatusUnfreeze(@Param("updatedStatus") Byte updatedStatus, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("superiorId") Long superiorId, @Param("status") Byte status, @Param("freezeTime") Date freezeTime);

    BigDecimal sumFreeze(@Param("superiorId") Long superiorId, @Param("status") Byte status, @Param("businessType") Byte businessType);

    UserCommission findOneByOrderSkuId(@Param("orderSkuId") Long orderSkuId);

    List<UserCommission> findAllByOrderSkuId(@Param("orderSkuId") Long orderSkuId);

    List<UserCommission> findAllByOrderSkuIds(@Param("orderSkuIds") List<Long> orderSkuIds);

    List<UserCommission> findAllByStatusAndFreezeTime(@Param("status") Byte status, @Param("freezeTime") Date freezeTime);

    int updateStatusAndUpdatedAtById(@Param("updatedStatus") Byte updatedStatus, @Param("updatedUpdatedAt") Date updatedUpdatedAt, @Param("id") Long id);

    int updateStatusBySuperiorIdAndStatus(@Param("updatedStatus") Byte updatedStatus, @Param("superiorId") Long superiorId, @Param("status") Byte status);

    int updateStatusBySubordinateIdAndStatus(@Param("updatedStatus") Byte updatedStatus, @Param("subordinateId") Long subordinateId, @Param("status") Byte status);

    BigDecimal getTotalByTypes(@Param("superiorId") Long superiorId, @Param("types") List<Byte> types);

    List<CountByTimeVO> getTotalIncomeByMonth(@Param("superiorId") Long superiorId);

    IncomeTimeVO getIncomeTime(@Param("superiorId") Long superiorId, @Param("types") List<Byte> types);

    List<UserCommissionResp> getFreeList();

    List<CountByTypeVO> getIncomeCount(ListByTimeReq req);

    AmountByTypeVO getAmount(ListByTimeReq req);

    DirectPushIncomeVO getUserCommission(@Param("superior_id") Long superior_id, @Param("identity_type") Byte identity_type);

    DirectPushIncomeVO getTotalUserCommission(@Param("supereriorId") Long supereriorId);

    List<DirectPushIncomeVO> getUserCommissionDetailByTimeType(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("superiorId") Long superiorId);

    List<UserCommissionTimeTypeVO> getUserCommissionChange(@Param("timeType") Byte timeType, @Param("time") Date time, @Param("superiorId") Long superiorId);

    List<RankNicknamePerformanceVO> getRankByType(@Param("startTime") String startTime, @Param("endTime") String endTime);

    List<RankNicknamePerformanceVO> getCommissionRankByType(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<RankNicknamePerformanceVO> getUserCommissionRank(@Param("indentity_type") Byte indentity_type);

    RankNicknamePerformanceVO getChampionByRankType(@Param("indentity_type") Byte indentity_type, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    RankNicknamePerformanceVO getChampion(@Param("indentity_type") Byte indentity_type);

    AgentCommissionTotalVO getTotalUserAgentCommission(@Param("id") Long id, @Param("list") List<Byte> list);

    BigDecimal sumByUserIdAndBusinessTypeAndShopIdAndStatus(@Param("userId") Long userId, @Param("businessType") Byte businessType, @Param("shopId") Long shopId, @Param("status") Byte status);

    BigDecimal sumByUserIdAndBusinessTypeAndStatus(@Param("userId") Long userId, @Param("businessType") Byte businessType, @Param("status") Byte status);

    List<UserMoneyStatisticsVO> getUserMoneyIncomeStatistics(@Param("id") Long id, @Param("time") Date time);

    BigDecimal getPromotionIncome(@Param("id") Long id);

    BigDecimal getTotalAmount();

    List<PromotionIncomeStatisticsVO> getPromotionIncomeStatistics(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("superiorId") Long id);

    AvgPromotionIncomeVO getAvgPromotionIncome(@Param("type") Byte type);

    BigDecimal getIncomeByType(@Param("superiorId") Long superiorId, @Param("type") Byte type);

    List<CommissionByTypeVO> getMyCommission(@Param("id") Long id);

    BigDecimal getAmountByType(@Param("id") Long id, @Param("type") Byte type);

    List<MyDirectPushShopVO> getMyDirectPushShopList(@Param("id") Long id, @Param("type") Byte type);

    BigDecimal sumBySuperiorIdAndType(@Param("superiorId") Long superiorId, @Param("type") Byte type);

    List<PartnerRankVO> getPartnerRank(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    Long getPartnerRewardCount(@Param("startTime") String startTime, @Param("endTime") String endTime);

    Long countByTypeIn(@Param("list") List<Byte> list);

    List<AvgPromotionIncomeVO> getAllAvgPromotionIncome(@Param("list") List<Byte> bytes);

    List<DayCommissionVO> getDayCommission(PageReq req);

    BigDecimal getPromotionIncomeByType(@Param("id") Long id, @Param("list") List<Byte> list);

    BigDecimal getTotalAmountByType(List<Byte> partnerBytes);

    List<UserCommissionVO> getBossInviteCommissionList(Long id);

    List<UserCommission> findAllByOrderSkuIdInAndStatus(@Param("orderSkuIdCollection") Collection<Long> orderSkuIdCollection, @Param("status") Byte status);

    StatisticsVO sumPerformanceCommissionByType(@Param("userId") Long userId, @Param("type") Byte type);

    IncomeTimeVO getIncomeChange(Long userId);

    List<StatisticsVO> getCommissionByTimeRangePage(@Param("req") TimeTypeReq req);

    StatisticsVO getCommissionPageStatistics(UserCommissionReq req);

    List<UserCommission> findAllByTypeAndCreatedAt(@Param("type")Byte type);

    UserCommission findOneByOrderSkuIdAndType(@Param("orderSkuId")Long orderSkuId,@Param("type")Byte type);




}